const state = () => ({
    user: {
        username: '',
        token: ''
    },
    user_data: {
        photo: '',
        name: '',
        login_type: false 
    }
})

const getters = {}
const actions = {}

const mutations = {
    // 登录成功后，保存用户信息
    save_user(state, payload) {
        state.user = payload;
        state.user_data.login_type = true;
    },
    // 退出
    user_exit(state) {
        state.user_data.login_type = false;
        state.user = {};
    },
    // 更新用户数据
    up_user_data(state, payload) {
        state.user_data.photo = payload.photo;
        state.user_data.name = payload.name;
    }
}

export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations
}
